<template>
  <div class="diet">
    <div class="dietnav">
      <ul class="nav1">
        <p>
          <span>为活宝儿甄选</span>
          <i class="iconfont icon-youjiantou"></i>
        </p>
        <em class="iconfont icon-fangdajing"></em>
      </ul>
      <ul class="nav2">
        <li v-for="(v, i) in arr" :key="i" @click="funnav(i)">
          <span class="aaa">
            {{ v.navtitle }}
          </span>
        </li>
        <b class="iconfont icon-xiajiantou"></b>
      </ul>
    </div>
    <div class="container">
      <DietCon />
    </div>
    <Footer />
  </div>
</template>

<script>
import getlink from "../api/getlink.js";
import DietCon from "@/components/dietCon.vue";
export default {
  data() {
    return {
      arr: [],
    };
  },
  components: {
    DietCon,
  },
  created() {
    getlink("/data/list/xiaoming").then((ok) => {
      this.arr = ok.data.dietDetails;
    });
  },
  methods: {
    funnav(i) {
      console.log(i);
      let obj = JSON.stringify(this.arr[i]);
      this.$router.push({ name: "DietCon", query: { xiaod: obj } });
      console.log(obj);
    },
  },
};
</script>

<style scoped>
.aaa:hover {
  color: black;
}
.aaa:hover .aaa:nth-child(1) {
  color: #999;
}
.container {
  margin-bottom: 0.6rem;
  margin-top: 1.05rem;
}
.dietnav {
  width: 100%;
  position: fixed;
  top: 0;
  background-color: #fff;
}
.dietnav .nav1 {
  width: 100%;
  font-size: 0.22rem;
}
.dietnav ul {
  height: 0.5rem;
  display: flex;
  align-items: center;
  font-size: 0.18rem;
  font-weight: 700;
  text-align: center;
}
.dietnav .nav2 {
  border-top: 0.01rem solid #999;
  overflow-x: auto;
}
.dietnav p {
  width: 3.4rem;
}
.dietnav em {
  margin-right: 0.1rem;
}
.dietnav li {
  flex-shrink: 0;
  margin-left: 0.2rem;
  color: #999;
}
.dietnav b {
  float: right;
  width: 0.5rem;
  height: 0.5rem;
  position: fixed;
  right: 0;
  top: 0.5rem;
  text-align: center;
  line-height: 0.5rem;
  background-color: #fff;
  border-left: 0.01rem solid #999;
}
</style>